#include <iostream>
#include <vector>

using namespace std;
/**
 * @brief 2 <= n <= 104
encoded.length == n - 1
0 <= encoded[i] <= 10^5
0 <= first <= 10^5
 *
 */
class Solution
{
public:
    vector<int> decode(vector<int> encoded, int first)
    {
        vector<int> ans;
        ans.push_back(first);
        for (int num : encoded)
        {
            ans.push_back(num ^ first);
            first = ans.back();
        }
        return ans;
    }

    vector<int> decode_1(vector<int> encoded, int first)
    {
        for (int &n : encoded)
        {
            swap(first, n);
            first ^= n;
        }
        encoded.push_back(first);
        return encoded;
    }

    vector<int> decode_2(vector<int> &encoded, int first)
    {
        int size = encoded.size();
        vector<int> ans(size + 1);
        ans[0] = first;
        for (int i = 1; i < size + 1; i++)
        {
            ans[i] = ans[i - 1] ^ encoded[i - 1];
        }
        return ans;
    }
    vector<int> decode_3(vector<int> &encoded, int first)
    {
        vector<int> ans;
        ans.push_back(first);
        for (int i = 0; i < encoded.size(); i++)
        {
            ans.push_back(encoded[i] ^ ans[i]);
        }
        return ans;
    }
};
int main()
{
    Solution s;
    vector<int> ans = s.decode({6, 2, 7, 3}, 4);
    for (int a : ans)
    {
        cout << a << " ";
    }
    cout << endl;
    return 0;
}
